package com.onelap.bls.tc.activity.bluetooth_le;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;

import com.blankj.utilcode.util.AppUtils;

public class BluetoothDialogHelper {
    public static void showDialog(Context context, String title, String message, boolean showCancelBtn, final DialogBtnCallback dialogBtnCallback) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        if (title != null) builder.setTitle(title);
        if (message != null) builder.setMessage(message);
        builder.setCancelable(false);
        if (showCancelBtn) {
            builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogBtnCallback.dialogBtnCallback(0);
                }
            });
        }
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogBtnCallback.dialogBtnCallback(1);
            }
        });
        builder.create().show();
    }

    public interface DialogBtnCallback {
        void dialogBtnCallback(int type);  //type==0  取消  //type==1  确定
    }
}
